package string;

/**
 * Created with IntelliJ IDEA.
 * Description: 比较版本号
 * User: Li_yizYa
 * Date: 2025/9/4
 * Time: 21:50
 */
public class Solution7 {
    public static int compareVersion(String version1, String version2) {
        int m = version1.length();
        int n = version2.length();
        int i = 0;
        int j = 0;
        while (i < m || j < n) {
            int x = 0;
            while (i < m && version1.charAt(i) !='.') {
                x = x * 10 + version1.charAt(i) - '0';
                i++;
            }
            i++; // 跳过点号
            int y = 0;
            while (j < n && version2.charAt(j) != '.') {
                y = y * 10 + version2.charAt(j) - '0';
                j++;
            }
            j++;
            if (x != y) {
                return x > y ? 1 : -1;
            }
        }
        return 0;
    }
    public static void main(String[] args) {

    }
}
